/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.tools;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.io.FileUtils;

/**
 *
 * @author Austin
 */
public class tset {

    public static void main(String[] args) throws ParseException, IOException {
        List downloadFile = new ArrayList<String>();
        downloadFile.add("xxx");
        System.out.println(downloadFile.size());
        
        
        FileUtils.copyFileToDirectory(new File("D:\\123\\111\\pam_1_2_text.20170419092000.tar"), new File("D:\\123\\333"), true);
        
        try {
            Date o = new Date(1494396000000L);
            long t = System.currentTimeMillis()/1000000;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
            Date xx = sdf.parse("2017-05-10 14:08:11");
            xx.getTime();
            Date date = new Date();
            date.getHours();
//                date.g
            String time = sdf.format(date);
            System.out.println(time);
            // read file content from file
            StringBuffer sb = new StringBuffer();
            FileInputStream fis = new FileInputStream("C:\\Users\\Austin\\Desktop\\WX11_1427802800280_2253990_BIGMEM_GROUPMESSAGE_320100_WEIXIN.bcp");
            InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
            BufferedReader br = new BufferedReader(isr);
//            FileReader reader = new FileReader("C:\\Users\\Austin\\Desktop\\WX11_1427802800280_2253990_BIGMEM_GROUPMESSAGE_320100_WEIXIN.bcp");
//            BufferedReader br = new BufferedReader(reader);

            String str = null;
            FileWriter writer = null;
            BufferedWriter bw = null;
            writer = new FileWriter("C:\\Users\\Austin\\Desktop\\nohup2.out");
            bw = new BufferedWriter(writer);
            while ((str = br.readLine()) != null) {
                String[] content = str.split("\\t");
                bw.write("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  :" + content.length + "\n");
                for (String i : content) {
                    System.out.println(i);

                    bw.write(i + "\n");
                }

//                sb.append(str + "\n");
//                System.out.println(sb.toString());
            }
            bw.close();
            writer.close();
            br.close();
//            reader.close();

            // write string to file
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
